<?php
  session_start();
  header("content-type=textml; charset=utf-8");  //设置字符集
  require("config.php");  //包含数据库连接文件
if(empty($_COOKIE["u_name"]))
  {
	  echo "<script>alert('用户未登录！');window.location.href='signin.html';</script>";
  }
if(!empty($_POST['submit']))
{
  $username  = $_POST['username']; 
  $project  = $_POST['project'];  
  $date  = $_POST['date'];  
  $day  = $_POST['day'];  
  $insert_sql="INSERT INTO addtime (a_user,a_date,a_day,a_project,u_id) VALUES ('$username','$date','$day','$project','".$_COOKIE["u_id"]."')";
  $result = mysql_query($insert_sql);// 返回结果集，成功true，失败false
  if($result && mysql_affected_rows()>0)
  {
	  echo "<script>alert('操作成功!!!');window.location.href='add.html';</script>";
  }
  else
  {
	  echo "<script>alert('对不起，操作失败!!!');window.location.href='add.html';</script>";
  }
}
   mysql_close($con);
 ?>